﻿// ....................................................................................................................
//	Author: Copyright (C) 2012 Ing. Marek Hubal
//	Email: hubal@acasoftware.org
// ....................................................................................................................

using System;

namespace core
{
    /// <summary>Trieda IStatusStrip</summary>
    public class IStatusStrip : System.Windows.Forms.StatusStrip
    {
        /// <summary>Konstruktor</summary>
        public IStatusStrip()
        {
            SizingGrip = false; // Inicializacia
        }
    }

    /// <summary>Trieda ISimpleStatusStrip</summary>
    public class ISimpleStatusStrip : IStatusStrip
    {
        /// <summary>Metoda: OnResize</summary>
        /// <param name="e">parameter</param>
        protected override void OnResize(EventArgs e)
        {
            int C = Items.Count - 1;
            int W = 0;
            for (int i = 0; i < C; i++) W += Items[i].Width;
            Items[C].Width = ClientSize.Width - 26 - W;
        }

        /// <summary>Konstruktor</summary>
        /// <param name="pButtonsCount">pocet tlacidiel</param>
        /// <param name="pButtonNames">nazvy tlacidiel</param>
        /// <param name="pClickHandlers">click handlery</param>
        public ISimpleStatusStrip(int pButtonsCount = 0, string[] pButtonNames = null, EventHandler[] pClickHandlers = null)
            : base()
        {
            for (int i = 0; i < pButtonsCount; i++)
            {
                System.Windows.Forms.ToolStripButton B = new System.Windows.Forms.ToolStripButton(pButtonNames[i]); // Vytvorim tlacidlo
                if (pClickHandlers[i] != null) B.Click += pClickHandlers[i]; // Priradim handler
                B.AutoToolTip = false;
                Items.Add(B); // Zaradim 
                Items.Add(new System.Windows.Forms.ToolStripSeparator());
            }

            Items.Add(new System.Windows.Forms.ToolStripLabel()); // Zaradim jeden label
            Items[Items.Count - 1].AutoSize = false;
            Items[Items.Count - 1].TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
        }

        /// <summary>Property: SimpleText</summary>
        public string SimpleText
        {
            set
            {
                Items[Items.Count - 1].Text = " " + value;
                Items[Items.Count - 1].ToolTipText = " " + value;
                //if (!InvokeRequired) IApp.DoEvents(Handle);
            }
        }
    }
}
